package cn.com.lyb.job.controller;


import cn.com.lyb.core.response.ResultDTO;
import cn.com.lyb.job.entity.vo.JobInstanceVO;
import cn.com.lyb.job.service.IJobInstanceService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 任务实例表 前端控制器
 * </p>
 *
 * @author lvyuanbo
 * @since 2024-07-11
 */
@RestController
@RequestMapping("/jobInstance")
@Api(tags = "节点实例")
public class JobInstanceController {

    @Autowired
    private IJobInstanceService jobInstanceService;

    @GetMapping("/selectPage")
    @ApiOperation(value = "查询列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "start", value = "分页参数", required = true),
            @ApiImplicitParam(name = "length", value = "分页参数", required = true),
            @ApiImplicitParam(name = "status", value = "实例状态: 1 未开始  2 进行中 3 成功 4 失败"),
            @ApiImplicitParam(name = "jobId", value = "任务id"),
            @ApiImplicitParam(name = "workflowInstanceId", value = "工作流实例id")
    })
    public ResultDTO selectPage(String status, Integer start, Integer length, Long jobId, Long workflowInstanceId){
        List<JobInstanceVO> res = jobInstanceService.selectPage(status, start, length, jobId, workflowInstanceId);
        return ResultDTO.success(new PageInfo<>(res));
    }

}
